package com.wyp.didishige.wiget;

import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.view.Gravity;
import android.view.View;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.LinearLayout.LayoutParams;

import com.wyp.didishige.R;

public class User_Dialog extends Dialog{

	private LinearLayout hr_dialog_top_lay;

	private Button hr_dialog_cancel;
	private Context mContext;

	LayoutParams layoutParams=new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);

	OnHrDialogOKClickListener hrDialogOKClickListener;
	public User_Dialog(Context context, int theme) {
		super(context, theme);
		this.mContext=context;
	}

	public User_Dialog(Context context) {
		super(context);
		this.mContext=context;
	}
	@Override
	public boolean isShowing() {
		return super.isShowing();
	}

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.user_dialog);
		getWindow().setWindowAnimations(R.style.userDialogstyle);
		getWindow().setGravity(Gravity.BOTTOM);
		getWindow().setLayout(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
		initView();
	}

	public void addButton(Button button,final int position){
		hr_dialog_top_lay.addView(button, layoutParams);
		button.setOnClickListener(new View.OnClickListener() {

			@Override
			public void onClick(View v) {
				hrDialogOKClickListener.onClickPosition(position);
			}
		});
	}
	private void initView(){
		hr_dialog_top_lay=(LinearLayout) findViewById(R.id.hr_dialog_top_lay);

		hr_dialog_cancel=(Button) findViewById(R.id.dialog_cancel);
		hr_dialog_cancel.setOnClickListener(new View.OnClickListener() {
			
			@Override
			public void onClick(View v) {
				cancel();
			}
		});
	}
	
	@Override
	public void cancel() {
		super.cancel();
	}
	
	
	@Override
	public void show() {
		super.show();
	}

	public void setOnOKClick(OnHrDialogOKClickListener l){
		hrDialogOKClickListener=l;
	}
	public interface OnHrDialogOKClickListener{
		public int onClickPosition(int position);
	}
	
}
